package smedi.ismedi.web.bff.controller.inmail;

import com.smedi.ismedi.inmail.api.dto.request.safetyBoard.*;
import com.smedi.ismedi.inmail.api.dto.response.safetyBoard.*;
import com.smedi.ismedi.inmail.api.feign.RemoteSafetyBoardFeignApi;
import com.smedi.ismedi.labor.api.dto.response.LaborAssignmentDetailResponse;
import com.smedi.ismedi.labor.api.feign.RemoteLaborCoreFeignApi;
import com.smedi.ismedi.web.starter.common.PaginationData;
import com.smedi.ismedi.web.starter.common.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 安全看板BFF
 *
 * @author niuyanling
 * @date 2021/11/01
 */
@Slf4j
@Api(tags = "安全看板接口")
@RequestMapping(value = "/webbff/v1/safetyBoard")
@RestController
@AllArgsConstructor
public class SafetyBoardController {
    private final RemoteSafetyBoardFeignApi remoteSafetyBoardFeignApi;

    private final RemoteLaborCoreFeignApi remoteLaborCoreFeignApi;

    /**
     * 安全看板总览
     *
     * @return ResponseData<SafetyBoardOverviewResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "安全看板总览")
    @PostMapping(value = "/overview")
    ResponseData<SafetyBoardOverviewResponse> getSafetyBoardOverview() {
        return remoteSafetyBoardFeignApi.getSafetyBoardOverview();
    }

    /**
     * 劳务人员统计
     *
     * @return ResponseData<LaborStatisticsResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "劳务人员统计")
    @PostMapping(value = "/labor")
    ResponseData<LaborStatisticsResponse> getLaborStatistics() {
        return remoteSafetyBoardFeignApi.getLaborStatistics();
    }

    /**
     * 安全隐患统计
     *
     * @return ResponseData<HiddenDangerStatisticsResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "安全隐患统计")
    @PostMapping(value = "/hidden-danger")
    ResponseData<HiddenDangerStatisticsResponse> getHiddenDangerStatistics(@Validated @RequestBody HiddenDangerStatisticsRequest hiddenDangerStatisticsRequest) {
        return remoteSafetyBoardFeignApi.getHiddenDangerStatistics(hiddenDangerStatisticsRequest);
    }

    /**
     * 今日危大工程统计
     *
     * @return ResponseData<LaborStatisticsResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "今日危大工程统计")
    @PostMapping(value = "/major-hazard/today")
    ResponseData<MajorHazardPaginationData> getTodayMajorHazardPage(@Validated @RequestBody MajorHazardTodayPageRequest majorHazardTodayPageRequest) {
        return remoteSafetyBoardFeignApi.getTodayMajorHazardPage(majorHazardTodayPageRequest);
    }

    /**
     * 危险源统计
     *
     * @return ResponseData<LaborStatisticsResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "危险源统计")
    @PostMapping(value = "/danger-source")
    ResponseData<DangerSourcePaginationData> getTodayDangerSourcePage(@Validated @RequestBody DangerSourceTodayPageRequest dangerSourceTodayPageRequest) {
        return remoteSafetyBoardFeignApi.getTodayDangerSourcePage(dangerSourceTodayPageRequest);
    }

    /**
     * 安全检查（项目）统计
     *
     * @return ResponseData<List < SafetyCheckStatisticsInProjectResponse>>
     */
    @ApiOperation(httpMethod = "POST", value = "安全检查（项目）统计")
    @PostMapping(value = "/safety-check/project")
    ResponseData<List<SafetyCheckProjectStatisticsResponse>> getSafetyCheckProjectStatics(@Validated @RequestBody SafetyCheckStatisticsProjectRequest safetyCheckStatisticsProjectRequest) {
        return remoteSafetyBoardFeignApi.getSafetyCheckProjectStatics(safetyCheckStatisticsProjectRequest);
    }

    /**
     * 安全教育统计（项目）
     *
     * @param safetyEducationStatisticsProjectRequest 安全教育统计（项目）请求
     * @return ResponseData<List<SafetyEducationStatisticsInProjectResponse>>
     */
    @ApiOperation(httpMethod = "POST", value = "安全教育统计（项目）")
    @PostMapping(value = "/safety-education/project")
    ResponseData<List<SafetyEducationProjectStatisticsResponse>> getSafetyEducationProjectStatics(@Validated @RequestBody SafetyEducationStatisticsProjectRequest safetyEducationStatisticsProjectRequest) {
        return remoteSafetyBoardFeignApi.getSafetyEducationProjectStatics(safetyEducationStatisticsProjectRequest);
    }

    /**
     * 项目情况 统计
     *
     * @return ResponseData<ProjectStatisticsResponse>
     */
    @ApiOperation(httpMethod = "GET", value = "项目情况 统计")
    @GetMapping(value = "/project/status")
    ResponseData<ProjectStatisticsResponse> getProjectStatistics(){
        return remoteSafetyBoardFeignApi.getProjectStatistics();
    }

    /**
     * 项目情况统计下地区统计
     *
     * @param provinceName 省份名称
     * @return ResponseData<ProjectStatisticsByRegionResponse>
     */
    @ApiOperation(httpMethod = "GET", value = "项目情况统计下地区统计")
    @GetMapping(value = "/projectStatistics/region")
    @ApiImplicitParam(name = "provinceName", value = "省份名称", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class)
    ResponseData<ProjectStatisticsByRegionResponse> getProjectStatisticsByRegion(@Validated @RequestParam(value = "provinceName") String provinceName){
        return remoteSafetyBoardFeignApi.getProjectStatisticsByRegion(provinceName);
    }

    /**
     * 安全检查统计（总院）
     *
     * @return ResponseData<ProjectStatisticsResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "安全检查统计（总院）")
    @PostMapping(value = "/safety-check/institute")
    ResponseData<List<StatisticsNodeResponse>> getSafetyCheckInstituteStatics(@Validated @RequestBody SafetyCheckInstituteStatisticsRequest safetyCheckInstituteStatisticsRequest) {
        return remoteSafetyBoardFeignApi.getSafetyCheckInstituteStatics(safetyCheckInstituteStatisticsRequest);
    }

    /**
     * 安全检查统计（主体院）
     *
     * @return ResponseData<ProjectStatisticsResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "安全检查统计（主体院）")
    @PostMapping(value = "/safety-check/organization")
    ResponseData<List<StatisticsNodeResponse>> getSafetyCheckOrganizationStatics(@Validated @RequestBody SafetyCheckOrganizationStatisticsRequest safetyCheckOrganizationStatisticsRequest) {
        return remoteSafetyBoardFeignApi.getSafetyCheckOrganizationStatics(safetyCheckOrganizationStatisticsRequest);
    }

    /**
     * 安全隐患统计（总院）
     *
     * @return ResponseData<ProjectStatisticsResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "安全隐患统计（总院）")
    @PostMapping(value = "/hidden-danger/institute")
    ResponseData<List<StatisticsNodeResponse>> getHiddenDangerInstituteStatics(@Validated @RequestBody HiddenDangerInstituteStatisticsRequest hiddenDangerInstituteStatisticsRequest){
        return remoteSafetyBoardFeignApi.getHiddenDangerInstituteStatics(hiddenDangerInstituteStatisticsRequest);
    }

    /**
     * 安全隐患统计（主体院）
     *
     * @return ResponseData<ProjectStatisticsResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "安全隐患统计（主体院）")
    @PostMapping(value = "/hidden-danger/organization")
    ResponseData<List<StatisticsNodeResponse>> getHiddenDangerOrganizationStatics(@Validated @RequestBody HiddenDangerOrganizationStatisticsRequest hiddenDangerOrganizationStatisticsRequest) {
        return remoteSafetyBoardFeignApi.getHiddenDangerOrganizationStatics(hiddenDangerOrganizationStatisticsRequest);
    }

    /**
     * 安全隐患统计（项目）
     *
     * @param hiddenDangerStatisticsProjectRequest 安全隐患统计（项目）请求
     * @return ResponseData<List<HiddenDangerStatisticsInProjectResponse>>
     */
    @ApiOperation(httpMethod = "POST", value = "安全隐患统计（项目）")
    @PostMapping(value = "/hidden-danger/project")
    ResponseData<List<HiddenDangerProjectStatisticsResponse>> getHiddenDangerProjectStatics(@Validated @RequestBody HiddenDangerStatisticsProjectRequest hiddenDangerStatisticsProjectRequest) {
        return remoteSafetyBoardFeignApi.getHiddenDangerProjectStatics(hiddenDangerStatisticsProjectRequest);
    }

    /**
     * 劳务人员统计下高龄人员分页数据
     *
     * @return PaginationData<LaborDetailResponse>
     */
    @ApiOperation(httpMethod = "GET", value = "劳务人员统计下高龄人员分页数据")
    @GetMapping(value = "/laborStatistics/highAgePagination")
    ResponseData<PaginationData<LaborAssignmentDetailResponse>> getHighAgeLaborGenderPagination(@RequestParam("offset") Long offset,
                                                                                                @RequestParam("pageSize") Long pageSize) {
        PaginationData<LaborAssignmentDetailResponse> responsePaginationData = remoteLaborCoreFeignApi.getQueryLaborEffectiveProjectAssignmentMobilePagination(offset, pageSize, null, null, null, null, null, "在场", false, true, false).getData();

        return new ResponseData<PaginationData<LaborAssignmentDetailResponse>>().success(responsePaginationData);
    }
}
